package com.betterjr.modules.application;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.betterjr.common.web.ControllerExceptionHandler;
import com.betterjr.common.web.ControllerExceptionHandler.ExceptionHandler;
import com.betterjr.common.web.Servlets;

@Controller
@RequestMapping(value = "/Platform/Resource")
public class ResourceController {

    private static final Logger logger = LoggerFactory.getLogger(ResourceController.class);

    @Reference(interfaceClass = IAmsResourceService.class)
    private IAmsResourceService resourceService;

    /**
     * 
     * @Title: queryResourcesExtends 
     * @Description:  根据状态查询资源信息并且封装成新增菜单的时候使用
     * @param request
     * @param businStatus  状态  1 生效  9 不生效
     * @return 根据状态查询资源信息并且封装成新增菜单的时候使用
     * @throws 
     * @author xuyp
     * @date 2017年12月20日 上午10:40:12
     */
    @RequestMapping(value = "/queryResourcesExtends", method = RequestMethod.POST)
    public @ResponseBody String queryResourcesExtends(final HttpServletRequest request, String businStatus) {
        final Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("入参：" + anMap);
        return ControllerExceptionHandler.exec(new ExceptionHandler() {
            @Override
            public String handle() {
                return resourceService.webQueryResourcesExtends(businStatus);
            }
        }, "操作失败", logger);
    }

    /**
     * 
     * @Title: queryResources 
     * @Description:  根据状态查询资源信息 
     * @param request
     * @param businStatus 状态  1 生效  9 不生效
     * @return  根据状态查询资源信息 
     * @throws 
     * @author xuyp
     * @date 2017年12月20日 下午5:13:27
     */
    @RequestMapping(value = "/queryResources", method = RequestMethod.POST)
    public @ResponseBody String queryResources(final HttpServletRequest request, String businStatus) {
        final Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("入参：" + anMap);
        return ControllerExceptionHandler.exec(new ExceptionHandler() {
            @Override
            public String handle() {
                return resourceService.webQueryResources(businStatus);
            }
        }, "操作失败", logger);
    }

}
